]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
automount: only autorun volumes marked as allowed
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 22 Jun 2011 13:45:03 +0000 (09:45 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 13 Jul 2011 18:39:35 +0000 (14:39 -0400)
Port code from g-s-d to mark volumes as allowed for autorun, and check
for it when running the notification.

https://bugzilla.gnome.org/show_bug.cgi?id=653520

js/ui/automountManager.js
js/ui/autorunManager.js

index ab50582eda31dc10345b1bfc805c121eb2a48195..3ebeb12e62976050387dd485c7c3795b6a0f3b5d 100644 (file)
@@ -13,6 +13,8 @@ const ScreenSaver = imports.misc.screenSaver;
 const SETTINGS_SCHEMA = 'org.gnome.desktop.media-handling';
 const SETTING_ENABLE_AUTOMOUNT = 'automount';
 
+const AUTORUN_EXPIRE_TIMEOUT_SECS = 10;
+
 const ConsoleKitSessionIface = {
     name: 'org.freedesktop.ConsoleKit.Session',
     methods: [{ name: 'IsActive',
@@ -128,13 +130,6 @@ AutomountManager.prototype = {
         params = Params.parse(params, { checkSession: true,
                                         useMountOp: true });
 
-        if (!this._settings.get_boolean(SETTING_ENABLE_AUTOMOUNT))
-            return;
-
-        if (!volume.should_automount() ||
-            !volume.can_mount())
-            return;
-
         if (params.checkSession) {
             // if we're not in the current ConsoleKit session,
             // don't attempt automount
@@ -149,16 +144,32 @@ AutomountManager.prototype = {
             }
         }
 
+        if (!this._settings.get_boolean(SETTING_ENABLE_AUTOMOUNT) ||
+            !volume.should_automount() ||
+            !volume.can_mount()) {
+           // allow the autorun to run anyway; this can happen if the
+            // mount gets added programmatically later, even if 
+            // should_automount() or can_mount() are false, like for
+            // blank optical media.
+            this._allowAutorun(volume);
+            this._allowAutorunExpire(volume);
+
+            return;
+        }
+
         // TODO: mount op
         this._mountVolume(volume, null);
     },
 
     _mountVolume: function(volume, operation) {
+        this._allowAutorun(volume);
         volume.mount(0, operation, null,
                      Lang.bind(this, this._onVolumeMounted));
     },
 
     _onVolumeMounted: function(volume, res) {
+        this._allowAutorunExpire(volume);
+
         try {
             volume.mount_finish(res);
         } catch (e) {
@@ -172,5 +183,16 @@ AutomountManager.prototype = {
             this._volumeQueue.filter(function(element) {
                 return (element != volume);
             });
+    },
+
+    _allowAutorun: function(volume) {
+        volume.allowAutorun = true;
+    },
+
+    _allowAutorunExpire: function(volume) {
+        Mainloop.timeout_add_seconds(AUTORUN_EXPIRE_TIMEOUT_SECS, function() {
+            volume.allowAutorun = false;
+            return false;
+        });
     }
 }
index da24694799b33a856de6a009bf33573a77a5af47..0b37f808b59f6d1008de78771b502dfdd7ec5b8f 100644 (file)
@@ -30,7 +30,7 @@ function ignoreAutorunForMount(mount) {
     let volume = mount.get_volume();
 
     if ((root.is_native() && !isMountRootHidden(root)) ||
-        (volume && volume.should_automount()))
+        (volume && volume.allowAutorun && volume.should_automount()))
         return false;
 
     return true;